Structures
Example 3: Stack
wstruct node {
w int value;
w node *next;
w};
wint main() {
w node *root; This will be the unchanging 1st node
w root=new node; Now root points to a node struct
w root->next=NULL; //The node root points to has its  
w// next pointer set equal to NULL
w root->value=5; // By using the -> operator, you
w// can modify the node
w return 0; //a struct (root in this case) points to.
w}
An example shown here is a simple function to add up all of the integers in a single dimensioned array.
A structure type is usually defined near to the start of a file using the typedef statement. typedef defines and names a new type, allowing its use throughout the program. typedefs usually occur just after the #define and #include statements in a file.
Here is an example structure definition.
typedef struct {
    char name[64];
    char course[128];
    int age;
    int year_of_study;
 } student;
This defines a new type student which can be used to declare variables as follows.
    student st_rec;
This creates a variable called st_rec of type student. The variable has members called name, course, age and year_of_study.